/*
FilterRecords
Version 1.0
Desctription: Class contains method which filter records by comparing old, new records by using fields
			  as sent from trigger as filter criteria.
Author: Pratibh Prakash
Created Date: 10 Mar-2009  
*/
public class FilterRecords {
	
	private List<Account> filteredRecords_new = new List<Account>();
	private List<Account> filteredRecords_old = new List<Account>();
	private Set<Id> filterRecords_Ids = new Set<Id>();
	
	public FilterRecords(Account[] oldAccounts, Account[] newAccounts, List<String> filterFields){
		for(Integer i=0; i<oldAccounts.size(); i++){
			
			for(Integer j=0; j<filterFields.size(); j++){
				if(oldAccounts[i].get(filterFields.get(j))!=newAccounts[i].get(filterFields.get(j))){
					filteredRecords_new.add(newAccounts[i]);
					filterRecords_Ids.add(newAccounts[i].Id);
					filteredRecords_old.add(oldAccounts[i]);
					
					break;
				}
			}
		}
	}
	
	public List<Account> getFilteredRecords_new(){
		return filteredRecords_new;
	}
	public List<Account> getFilteredRecords_old(){
		return filteredRecords_old;
	}
	public Set<Id> getFilterRecordsIDs(){
		return filterRecords_Ids;
	}
}